@extends('common.admin_template')

@section('content')
    <div class="boxWidth">
        @include('common.notice_msg')
        <div class="row searchLine">
            <div class="col-xs-6 ">
                <a href="{{url('admin/shops/new')}}" target="_blank"><button class="btn btn-default searchBtn">新建商铺</button></a>
            </div>
            <div class="col-xs-6 searchInput">
                <input type="text" id="searchInput">
                <button class="btn btn-default searchBtn" id="searchCon">搜索</button>
            </div>
        </div>
            <table class="table table-hover adminTableBg">
                <thead>
                <tr>
                    <th class="col-xs-2">名称</th>
                    <th class="col-xs-3">地址</th>
                    <th class="col-xs-2">联系电话</th>
                    <th class="col-xs-1">管理者</th>
                    <th class="col-xs-1">状态</th>
                    <th class="col-xs-2">时间</th>
                    <th class="col-xs-1">操作</th>
                </tr>
                </thead>
                <tbody>
                <?php $statusName = ['待审','通过']; ?>
                @foreach($Shops as $shop)
                    <tr>
                        <th class="col-xs-2 itemTd">{{$shop->name}}</th>
                        <th class="col-xs-3 itemTd">{{$shop->address}}</th>
                        <th class="col-xs-2 itemTd">{{$shop->phone}}</th>
                        <th class="col-xs-1 itemTd">{{$shop->user}}</th>
                        <th class="col-xs-1 itemTd">{{$statusName[$shop->status]}}</th>
                        <th class="col-xs-2 itemTd">{{$shop->created_at}}</th>
                        <th class="col-xs-1 itemTd">
                            <a href="{{url('admin/cats?shop='.$shop->id)}}"><span id="addInput">分类</span></a>
                            <a href="{{url('admin/goods?shop='.$shop->id)}}"><span >商品</span></a>
                            <a href="{{url('admin/shops/edit',['id' => $shop->id])}}"><span >编辑</span></a>
                            <a href="{{url('admin/shops/del',['id' => $shop->id])}}"><span class="redColor" id="delInput" onclick="if(!confirm('是否确认删除？'))return false">删除</span></a>
                        </th>
                    </tr>
                @endforeach
                </tbody>
            </table>
        <div class="pull-right">
            <?php
                $s=isset($_GET['s'])?$_GET['s']:'';
                if($s){
                    $url = ['s' => $s];
                }else{
                    $url = [];
                }
            ?>
            {!! $Shops->appends($url)->render() !!}
        </div>
    </div>
@stop
@section('js')
    <script>
        (function () {
            $('#searchCon').on('click',function () {
                var url = $('#searchInput').val().replace(/(^\s*)|(\s*$)/g, "");
                if(url){
                    window.location.href= "{!! url('admin/shops?s=') !!}"+url;
                }else{
                    window.location.href= "{!! url('admin/shops') !!}"
                }
            });
        })()
    </script>
@stop